<template>
    <div>
      <div class="top">
        <div @click="backHome">
          <i class="el-icon-arrow-left icon"></i>
        </div>
        <div class="top-title">错题库</div>
      </div>
      <div class="tip" v-for = "item of errorTip" :key = "item.id">
        <div class="tip-left">{{item.title}}</div>
        <div class="tip-desc">属于</div>
        <div class="tip-right">{{item.type}}</div>
      </div>
    </div>
</template>

<script>
import axios from 'axios'

export default {
  data () {
    return {
      errorTip: []
    }
  },
  methods: {
    backHome () {
      window.history.go(-1)
    }
  },
  mounted () {
    axios({
      methods: 'post',
      url: '/api/titles.json'
    }).then((res) => {
      if ((res.status === 200) && res.data) {
        res = res.data.data
        this.errorTip = res.titles
      }
    })
  }
}
</script>

<style lang="scss" scoped>
@import "../../assets/styles/global";
.top{
  display: flex;
  width: 100%;
  height: 37px;
  line-height: 37px;
  text-align: center;
  font-size: 17px;
  background: skyblue;
  .icon{
    float: left;
    width: 50%;
    overflow: hidden;
    font-size: 20px;
    margin-left: 10px;
  }
  .top-title{
    flex: 1;
    margin-right: 45px;
  }
}
.tip{
  display: flex;
  height: .9rem;
  line-height: .9rem;
  width: 96%;
  margin: .2rem auto;
  background: white;
  text-align: center;
  border-radius: 10px;
  .tip-left{
    width: 35%;
    float: left;
  }
  .tip-desc{
    flex: 1;
  }
  .tip-right{
    width: 35%;
    float: right;
  }
}
</style>
